//
//  XMMineViewController.m
//  XMJJ_zml
//
//  Created by apple on 2025/5/9.
//

#import "PersonMainPageViewController.h"
#import "XMPersonView.h"
#import "XMNetwork+mine.h"
#import "XMAddFriendViewController.h"
#import "XMSetViewController.h"
#import "XMHomePageEditViewController.h"
#import "RoundedSearchBar.h"
#import "XMShopViewController.h"
@interface PersonMainPageViewController ()<XMPersonViewDelegate>

@property (nonatomic, strong) XMPersonView *mineView;

@end

@implementation PersonMainPageViewController

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [self hideNavigationBar:YES animated:YES];
    for (UIView *subview in self.navigationController.view.subviews) {
            // 这里可以对每个子视图进行你想要的操作，比如打印子视图的描述信息
            NSLog(@"Subview description: %@", subview);
        if([subview isKindOfClass:[RoundedSearchBar class]]){
            subview.hidden = YES;
        }
     }
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self creatUI];
}

- (void)creatUI {
    [self.view addSubview:self.mineView];
    [self getUserInfo];
}

- (void)getUserInfo {
//    XMWeakSelf;
//    [_Network getHomePageInfoSuccess:^(id  _Nonnull responseObject) {
//        XMUserInfoModel *userInfoModel = [XMUserInfoModel yy_modelWithJSON:[responseObject objectForKey:@"data"]];
//        [weakSelf.mineView setContentWithUserInfoModel:userInfoModel];
//    } failure:^(NSError * _Nonnull error) {
//        
//    }];
//    [_Network getUserInfoSuccess:^(id  _Nonnull responseObject) {
//        XMUserInfoModel *userInfModel = [XMUserInfoModel yy_modelWithJSON:[responseObject objectForKey:@"data"]];
//        [weakSelf.mineView setContentWithUserInfoModel:userInfModel];
//    } failure:^(NSError * _Nonnull error) {
//
//    }];
}

- (void)goShop
{
    XMShopViewController * xmShopVc = [XMShopViewController new];
    xmShopVc.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:xmShopVc animated:YES];
}
//添加朋友
- (void)attionAction {
    
//    XMShopViewController * xmShopVc = [XMShopViewController new];
//    xmShopVc.hidesBottomBarWhenPushed = YES;
//    [self.navigationController pushViewController:xmShopVc animated:YES];
}

//设置
- (void)sendMessageAction {
    
//    XMSetViewController *setVC = [[XMSetViewController alloc] init];
//    setVC.hidesBottomBarWhenPushed = YES;
//    [self.navigationController pushViewController:setVC animated:YES];
}

//编辑主页
- (void)homePageEdit {
    XMHomePageEditViewController *homePageEditVC = [[XMHomePageEditViewController alloc] init];
    homePageEditVC.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:homePageEditVC animated:YES];
}

#pragma mark - Init
- (XMPersonView *)mineView {
    if (!_mineView) {
        _mineView = [[XMPersonView alloc] initWithFrame:CGRectMake(0, 0, self.view.width, self.view.height-self.view.safeAreaInsets.bottom - 50)];
        _mineView.delegate = self;
    }
    return _mineView;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
